﻿using Common.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Database.Mappers
{
    public partial class Mapper
    {
        public TileDTO Map(Tile tile)
        {
            return new TileDTO
            {
                Id = tile.Id,
                TileType = Map(tile.TileType),
                X = tile.X,
                Y = tile.Y,
                GraphicTile = tile.GraphicTile
            };
        }

        public Tile Map(TileDTO tile)
        {
            return new Tile
            {
                Id = tile.Id,
                TileType = Map(tile.TileType),
                X = tile.X,
                Y = tile.Y,
                GraphicTile = tile.GraphicTile
            };
        }

        public List<TileDTO> Map(ICollection<Tile> tiles)
        {
            return tiles.Select(gameObjectDto => new TileDTO()
            {
                Id = gameObjectDto.Id,
                TileType = Map(gameObjectDto.TileType),
                X = gameObjectDto.X,
                Y = gameObjectDto.Y,
                GraphicTile = gameObjectDto.GraphicTile
            }).ToList();
        }

        public ICollection<Tile> Map(List<TileDTO> tiles)
        {
            return tiles.Select(gameObject => new Tile()
            {
                Id = gameObject.Id,
                TileType = Map(gameObject.TileType),
                X = gameObject.X,
                Y = gameObject.Y,
                GraphicTile = gameObject.GraphicTile
            }).ToList();
        }
    }
}
